package com.szq.ai.healthcare.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.szq.ai.healthcare.entity.Appointment;
import com.szq.ai.healthcare.mapper.AppointmentMapper;
import com.szq.ai.healthcare.service.AppointmentService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author: szq
 * @description:
 * @date: 2025-05-28 10:13:19
 * @return
 */
@Service
public class AppointmentImpl extends ServiceImpl<AppointmentMapper, Appointment> implements AppointmentService {

    /**
     * 查询订单是否存在
     * @param appointment
     * @return
     */
    @Override
    public Appointment getOne(Appointment appointment) {
        LambdaQueryWrapper<Appointment> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.hasLength(appointment.getUsername())) {
            queryWrapper.eq(Appointment::getUsername, appointment.getUsername());
        }
        if (StringUtils.hasLength(appointment.getIdCard())) {
            queryWrapper.eq(Appointment::getIdCard, appointment.getIdCard());
        }
        if (StringUtils.hasLength(appointment.getDepartment())) {
            queryWrapper.eq(Appointment::getDepartment, appointment.getDepartment());
        }
        if (StringUtils.hasLength(appointment.getDate())) {
            queryWrapper.eq(Appointment::getDate, appointment.getDate());
        }
        if (StringUtils.hasLength(appointment.getTime())) {
            queryWrapper.eq(Appointment::getTime, appointment.getTime());
        }
        Appointment result = baseMapper.selectOne(queryWrapper);
        return result;
    }
}
